/*
 * User class for the Conference Application
 * Author: Jonathan Forbes
 * TCSS 360 Spring 2013 
 * University of Washington
 */

package Model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Observable;

public class User  extends Observable implements Serializable{
	
	/**
	 * Class that holds the Model of the User object, which holds such pertinent data such as:
	 * the user's login credentials, full name, email address, permissions (roles), and lists
	 * of papers for any role the user might have. 
	 * 
	 * @author Jonathan Forbes
	 * @version 1.0
	 */
	private static final long serialVersionUID = 1L;

	private String login;
	
	private String password;
	
	private String email;
	
	private String fullname;
	
	private boolean[] permissions;
	
	private List<Paper> papers;
	
	private List<Paper> review_papers;
	
	private List<Paper> subprogram_papers;
	
	private List<Paper> program_papers;
	
	public User(String login, String password, String email, String fullname) {
		this(login, password, email, fullname, false);
	}
	
	public User(String login, String password, String email, String fullname, boolean admin) {
		this.login = login;
		this.password = password;
		this.email = email;
		this.fullname = fullname;
		
		// Brand new users start with no extra permissions, they are just plain users. The only
		// Admin user is hard coded into the program, for now...
		// permission order: 0:Author, 1:Reviewer, 2:SPC, 3:PC, 4:Admin
		permissions = new boolean[]{false, false, false, false, admin};
		
		papers = new ArrayList<Paper>();
		review_papers = new ArrayList<Paper>();
		subprogram_papers = new ArrayList<Paper>();
		program_papers = new ArrayList<Paper>();
	}
	
	public String getLogin() {
		return login;
	}
	
	public void setLogin(String the_login) {
		login = the_login;
	}
	
	public String getPassword() {
		return password;
	}
	
	public void setPassword(String the_password) {
		password = the_password;
	}
	
	public String getEmail() {
		return email;
	}
	
	public void setEmail(String the_email) {
		email = the_email;
	}
	
	public String getfullname() {
		return fullname;
	}
	
	public void setFullname(String the_fullname) {
		fullname = the_fullname;
	}
	
	public List<Paper> getAuthorPapers() {
		return papers;
	}
	
	public List<Paper> getReviewPapers() {
		return review_papers;
	}
	
	public List<Paper> getSPCPapers() {
		return subprogram_papers;
	}
	
	public List<Paper> getPCPapers() {
		return program_papers;
	}
	
	public void addPaper(Paper the_paper) {
		papers.add(the_paper);
	}
	
	public void addReviewerPaper(Paper the_paper) {
		review_papers.add(the_paper);
	}
	
	public void addSPCPaper(Paper the_paper) {
		subprogram_papers.add(the_paper);
	}
	
	public void addPCPaper(Paper the_paper) {
		program_papers.add(the_paper);
	}
	
	// NOTICE: This method is depreciated and is only left here for the sake of the MailFileTest
	public void setPCPapers(List<Paper> the_list) {
		program_papers = the_list;
	}
	
	public void removePaper(Paper the_paper) {
		papers.remove(the_paper);
	}
	
	public void setPermission(int permission, boolean setting) {
		permissions[permission] = setting;
	}
	
	public boolean[] getPermissions() {
		return permissions;
	}
	
	
}